package com.assist.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.assist.dao.IActivityDAO;
import com.assist.model.Activity;
import com.assist.model.Category;
import com.assist.util.HibernateUtil;

public class ActivityDAOImpl implements IActivityDAO{

	@Override
	public void saveOrUpdateActivity(Activity activity) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.saveOrUpdate(activity);
		
	}

	@Override
	public List<Activity> getActivitiesByUserName(String userName) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		Criteria criteria = session.createCriteria(Activity.class);
		criteria.add(Restrictions.eq("owner", userName));
		List<Activity> results = criteria.list();
		return (List<Activity>) results;
	}

}
